﻿using System.Data;

namespace RuoVea.OmiApi.Reports.Util;

/// <summary>
/// 
/// </summary>
public static class DictionaryExtensions
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="oldDictionary"></param>
    /// <param name="replaceIt"></param>
    /// <param name="withIt"></param>
    /// <returns></returns>
    public static Dictionary<string, string> ReplaceInKeys(this IDictionary<string, string> oldDictionary, string replaceIt, string withIt)
    {
        // Do all the works with just one line of code:
        return oldDictionary.Select(x => new KeyValuePair<string, string>(x.Key.Replace(replaceIt, withIt), x.Value)).ToDictionary(x => x.Key, x => x.Value);
    }
}
